package com.cyc.stream;

import java.util.Arrays;
import java.util.List;

public class Test {
    public static void main(String[] args) {
        User user1 = new User(1,"a",12);
        User user2 = new User(2,"b",22);
        User user3 = new User(3,"c",32);
        User user4 = new User(4,"d",42);
        User user5 = new User(5,"e",52);
        User user6 = new User(6,"F",62);
        //集合存储
        List<User> users = Arrays.asList(user1, user2, user3, user4, user5,user6);
        //计算交给流
        //1.找出id为偶数的user
        //2.找出年龄大于23
        //3.将名字大写
        //4.倒序
        //5.只输出一个
        // lambda 链式编程 函数型接口 stream流式计算
        users.stream().filter(u->{
            return u.getId()%2==0;
        }).filter(u->{
            return u.getAge()>23;
        }).map(u->{
            return u.getName().toUpperCase();
        }).sorted((uu1,uu2)->{
            return uu2.compareTo(uu1);
        }).limit(1).forEach(System.out::println);


    }
}
